﻿using Microsoft.Graphics.Canvas.Effects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Documents;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using 纸片人.ConvertClass;
using 纸片人.win2dEffectControl.DataClass;

using 纸片人.CalculateControls;
// The Templated Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234235

namespace 纸片人.win2dEffectControl
{
    public sealed class ShadowEffectControl : EffectControl
    {
        private ColorPicker colorPicker;
        private Vector4Control colorHdrVector4Control;
        private TextBoxSlider blurAmountTexBoxSlider;
        private ComboBox optimizationComboBox;
        public override EffectOneSourceData OneEffetData { get; set; }

        List<EffectOptimization> listEffectOptimization = new List<EffectOptimization>();
        public ShadowEffectControl()
        {
            this.DefaultStyleKey = typeof(ShadowEffectControl);
            listEffectOptimization=EffectUtil.GetEnumList<EffectOptimization>();
            OneEffetData = new ShadowEffectData();
        }

        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            SetEffectName("阴影效果", "ShadowEffect");

            colorPicker = GetTemplateChildFormName<ColorPicker>(nameof(colorPicker));
            CreateBinding(OneEffetData, "", nameof(ShadowEffectData.ShadowColor), colorPicker, ColorPicker.ColorProperty);

            optimizationComboBox = GetTemplateChildFormName<ComboBox>(nameof(optimizationComboBox));
            SetComboBox(optimizationComboBox, listEffectOptimization, OneEffetData, nameof(ShadowEffectData.Optimization));



            blurAmountTexBoxSlider = GetTemplateChildFormName<TextBoxSlider>(nameof(blurAmountTexBoxSlider));
            SetTextBoxSlider(blurAmountTexBoxSlider, OneEffetData, nameof(ShadowEffectData.BlurAmount));
            colorHdrVector4Control = GetTemplateChildFormName<Vector4Control>(nameof(colorHdrVector4Control));
            SetVector4Control(colorHdrVector4Control, OneEffetData, nameof(ShadowEffectData.ShadowColorHdr));
        }

    }
}